<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>bkn.bibtex.merge_tools</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bkn.bibtex-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bibkn/">bkn.bibtex</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;bkn ::
        <a href="bkn.bibtex-module.html">Package&nbsp;bibtex</a> ::
        Module&nbsp;merge_tools
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="bkn.bibtex.merge_tools-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module merge_tools</h1><p class="nomargin-top"><span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html">source&nbsp;code</a></span></p>
<p>Tools for merging bibliographys [Currently broken!]</p>

<hr />
<div class="fields">      <p><strong>Status:</strong>
        The code in this module was poorly thought out and is of limited 
        usefulness.
      </p>
      <p><strong>Copyright:</strong>
        (c) 2009-2010, Benjamin Kalish
      </p>
      <p><strong>License:</strong>
        This program is free software; you can redistribute it and/or 
        modify it under the terms of the GNU General Public License as 
        published by the Free Software Foundation; either version 2 of the 
        License, or (at your option) any later version.
        <p>This program is distributed in the hope that it will be useful, 
        but WITHOUT ANY WARRANTY; without even the implied warranty of 
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
        General Public License for more details.</p>
      </p>
      <p><strong>Deprecated:</strong>
        This entire module has been replaced by <a 
    href="bkn.bibtex.new_merge_tools-module.html" 
    class="link">new_merge_tools</a>.
      </p>
</div><!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">string</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bkn.bibtex.merge_tools-module.html#title_hash" class="summary-sig-name">title_hash</a>(<span class="summary-sig-arg">entry</span>)</span><br />
      The default hash_function for use with <a 
      href="bkn.bibtex.merge_tools-module.html#merge_bibliographies" 
      class="link">merge_bibliographies()</a>.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#title_hash">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><a href="bkn.bibtex.bibliography.Bibliography-class.html" 
      class="link">Bibliography</a></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bkn.bibtex.merge_tools-module.html#merge_bibliographies" class="summary-sig-name">merge_bibliographies</a>(<span class="summary-sig-arg">bibliographies</span>,
        <span class="summary-sig-arg">hash_function</span>=<span class="summary-sig-default">title_hash</span>,
        <span class="summary-sig-arg">whitelist</span>=<span class="summary-sig-default">None</span>)</span><br />
      Merges a list of bibliographies.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#merge_bibliographies">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">None</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bkn.bibtex.merge_tools-module.html#persitent_keys_from_file" class="summary-sig-name">persitent_keys_from_file</a>(<span class="summary-sig-arg">bib</span>,
        <span class="summary-sig-arg">filename</span>,
        <span class="summary-sig-arg">hash_function</span>=<span class="summary-sig-default">title_hash</span>,
        <span class="summary-sig-arg">prefix</span>=<span class="summary-sig-default">None</span>)</span><br />
      Assigns citekeys from the specified file.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#persitent_keys_from_file">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">None</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bkn.bibtex.merge_tools-module.html#write_correctable_bibtex" class="summary-sig-name">write_correctable_bibtex</a>(<span class="summary-sig-arg">bibliography</span>,
        <span class="summary-sig-arg">filename</span>)</span><br />
      Writes a bibliography to a BibTeX file with checksums to be used in 
      conjunction with <a 
      href="bkn.bibtex.merge_tools-module.html#apply_corrections" 
      class="link">apply_corrections()</a>.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#write_correctable_bibtex">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">None</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bkn.bibtex.merge_tools-module.html#apply_corrections" class="summary-sig-name">apply_corrections</a>(<span class="summary-sig-arg">bibliography</span>,
        <span class="summary-sig-arg">filename</span>)</span><br />
      Returns a bibliography with corrections taken from a file.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#apply_corrections">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_values_differ"></a><span class="summary-sig-name">_values_differ</span>(<span class="summary-sig-arg">list_</span>)</span><br />
      Returns true if values in list differ.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#_values_differ">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_clean_title"></a><span class="summary-sig-name">_clean_title</span>(<span class="summary-sig-arg">t</span>)</span><br />
      Cleans a title string for indexing.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#_clean_title">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_normalize_fields"></a><span class="summary-sig-name">_normalize_fields</span>(<span class="summary-sig-arg">bib_entry</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#_normalize_fields">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_sum_lists"></a><span class="summary-sig-name">_sum_lists</span>(<span class="summary-sig-arg">list_of_lists</span>)</span><br />
      Returns the sum of the lists in list.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#_sum_lists">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_remove_dups"></a><span class="summary-sig-name">_remove_dups</span>(<span class="summary-sig-arg">list_</span>)</span><br />
      Rmoves duplicates from a list.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#_remove_dups">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="bkn.bibtex.merge_tools-module.html#_MERGE_WARNING_TEMPLATE" class="summary-name" onclick="show_private();">_MERGE_WARNING_TEMPLATE</a> = <code title="'{0.parent_bib.name:10}:{0.citekey:20} {1}'">'{0.parent_bib.name:10}:{0.citekey:2<code class="variable-ellipsis">...</code></code><br />
      A format string for use in reporting errors when merging.
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="bkn.bibtex.merge_tools-module.html#_CORRECTION_WARNING_TEMPLATE" class="summary-name" onclick="show_private();">_CORRECTION_WARNING_TEMPLATE</a> = <code title="'Warning! Applying correction to {0.citekey} which has changed'">'Warning! Applying correction t<code class="variable-ellipsis">...</code></code><br />
      A format string for use in reporting errors when applying 
      corrections.
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="bkn.bibtex.merge_tools-module.html#_PAGE_RANGE_PATTERN" class="summary-name" onclick="show_private();">_PAGE_RANGE_PATTERN</a> = <code title="re.compile(r'(\d)-(\d)')">re.compile(r'(\d)-(\d)')</code><br />
      Matches a set of digits seperated by hyphens.
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="title_hash"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">title_hash</span>(<span class="sig-arg">entry</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#title_hash">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>The default hash_function for use with <a 
  href="bkn.bibtex.merge_tools-module.html#merge_bibliographies" 
  class="link">merge_bibliographies()</a>.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>entry</code></strong> (<a href="bkn.bibtex.bibliography.BibEntry-class.html" 
          class="link">BibEntry</a>) - the entry to be considered</li>
    </ul></dd>
    <dt>Returns: string</dt>
        <dd>Always returns the same value for entries with strings which are 
          considered sufficiently similar. If the entry does not have a 
          title field then a cryptographic hash of the entry is returned. 
          This makes it improable that two distinct entries without titles 
          will return the same value.</dd>
  </dl>
<div class="fields">      <p><strong>Warning:</strong>
        This function ignores mathematics completely, so that calling this 
        method on entries with the titles:
<pre class="literalblock">
   New ideas about a classic formula: $a^2 + b^2 = c^2$
   New ideas about a classic formula: $E = m c^2$
   New ideas about a classic formula: $Spam + Eggs$
</pre>
        <p>will return the the same value.</p>
      </p>
</div></td></tr></table>
</div>
<a name="merge_bibliographies"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">merge_bibliographies</span>(<span class="sig-arg">bibliographies</span>,
        <span class="sig-arg">hash_function</span>=<span class="sig-default">title_hash</span>,
        <span class="sig-arg">whitelist</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#merge_bibliographies">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Merges a list of bibliographies.</p>
  <p>hash_function, if supplied, should be a function which taking a <a 
  href="bkn.bibtex.bibliography.BibEntry-class.html" 
  class="link">BibEntry</a> as an argument and must always return the same,
  hashable, value for entries which are to be merged, and distinct values 
  for entries which should not be merged.</p>
  <p>This function adds a couple of new attributes to the entries in the 
  merged bibliography:</p>
  <ol start="1">
    <li>
      <code>merge_sources</code> - a string listing the names of the bibs 
      which were merged to create this entry.
    </li>
    <li>
      <code>merge_warnings</code> - a string giving any warnings about 
      conflicting values for this entry.
    </li>
  </ol>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>bibliographies</code></strong> (list of <a href="bkn.bibtex.bibliography.Bibliography-class.html"
          class="link">Bibliography</a> objects.) - the bibliographies to be merged</li>
        <li><strong class="pname"><code>hash_function</code></strong> (function) - a hash function used to identify duplicate records.</li>
        <li><strong class="pname"><code>whitelist</code></strong> (list of strings) - if not None, then only the fields named in this list will be 
          preserved during the merge.</li>
    </ul></dd>
    <dt>Returns: <a href="bkn.bibtex.bibliography.Bibliography-class.html" 
      class="link">Bibliography</a></dt>
        <dd>the merged bibliography.</dd>
  </dl>
</td></tr></table>
</div>
<a name="persitent_keys_from_file"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">persitent_keys_from_file</span>(<span class="sig-arg">bib</span>,
        <span class="sig-arg">filename</span>,
        <span class="sig-arg">hash_function</span>=<span class="sig-default">title_hash</span>,
        <span class="sig-arg">prefix</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#persitent_keys_from_file">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Assigns citekeys from the specified file.</p>
  <p>Assigns citekeys from the specified file, using 
  <code>hash_function</code> to identify which citekey to assign to which 
  BibEntry.</p>
  <p>Entries with no corresponding citekey in the file will be a numerical 
  citekey, whose value will be added to the file. Values for new citekeys 
  begin at one more than the number of citekyes in the file.</p>
  <p>If the optional prefix is supplied, it will be used before any new 
  numerical citekeys.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>bib</code></strong> (<a href="bkn.bibtex.bibliography.Bibliography-class.html" 
          class="link">Bibliography</a>) - the bibliography whose citekeys should be changed</li>
        <li><strong class="pname"><code>filename</code></strong> (string) - a path to the citekey file</li>
        <li><strong class="pname"><code>hash_function</code></strong> (function) - a hash function, as in <a 
          href="bkn.bibtex.merge_tools-module.html#merge_bibliographies" 
          class="link">merge_bibliographies()</a></li>
        <li><strong class="pname"><code>prefix</code></strong> (string) - a prefix to use as the start of new citekeys</li>
    </ul></dd>
    <dt>Returns: None</dt>
  </dl>
<div class="fields">      <p><strong>Attention:</strong>
        This function will only assign unique citekeys if the 
        <code>hash_function</code> gives a unique value for each entry in 
        the bibliography.
      </p>
      <p><strong>Warning:</strong>
        This function assumes that numerical keys greater than the number 
        of keys already assigned have not yet been used. Care should be 
        taken when editing the citekey file.
      </p>
</div></td></tr></table>
</div>
<a name="write_correctable_bibtex"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">write_correctable_bibtex</span>(<span class="sig-arg">bibliography</span>,
        <span class="sig-arg">filename</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#write_correctable_bibtex">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Writes a bibliography to a BibTeX file with checksums to be used in 
  conjunction with <a 
  href="bkn.bibtex.merge_tools-module.html#apply_corrections" 
  class="link">apply_corrections()</a>.</p>
  <p>write_correctable_bibtex produces a BibTeX file which has been 
  enchanced in the following ways:</p>
  <ol start="1">
    <li>
      Each entry is given a checksum field. This checksum is required by <a
      href="bkn.bibtex.merge_tools-module.html#apply_corrections" 
      class="link">apply_corrections()</a> in order to produce warnings 
      when a correction is applied to an entry which has changed.
    </li>
    <li>
      BibTeX warnings are added in comments before each entry.
    </li>
    <li>
      If the bibliography was generated using <a 
      href="bkn.bibtex.merge_tools-module.html#merge_bibliographies" 
      class="link">merge_bibliographies</a> then all warnings generated 
      during the merge operation are included as comments before each 
      entry.
    </li>
    <li>
      If the bibliography was generated using <a 
      href="bkn.bibtex.merge_tools-module.html#merge_bibliographies" 
      class="link">merge_bibliographies</a> then a list of the sources for 
      each entry is listed in a comment before each entry. (References to 
      entries are refered to by the name of the bib followed by a colon 
      followed by the citekey in that bib.)
    </li>
  </ol>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>bibliography</code></strong> (<a href="bkn.bibtex.bibliography.Bibliography-class.html" 
          class="link">Bibliography</a>) - a merged bibliography (it is an error to pass an unmerged 
          bibliography)</li>
        <li><strong class="pname"><code>filename</code></strong> (string) - the name of the file to be created</li>
    </ul></dd>
    <dt>Returns: None</dt>
  </dl>
</td></tr></table>
</div>
<a name="apply_corrections"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">apply_corrections</span>(<span class="sig-arg">bibliography</span>,
        <span class="sig-arg">filename</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bkn.bibtex.merge_tools-pysrc.html#apply_corrections">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Returns a bibliography with corrections taken from a file.</p>
  <p>Care must be taken when applying corrections to bibliographic data 
  from a source that may change. This function reads an edited version of 
  the bibliography generated using <a 
  href="bkn.bibtex.merge_tools-module.html#write_correctable_bibtex" 
  class="link">write_correctable_bibtex</a> and compares the checksums in 
  that file to checksums generated from the supllied bibliography. A 
  warning is generated for each correction which is applied to an entry 
  which has changed.</p>
  <p>Corrections are applied as follows:</p>
  <ul>
    <li>
      To delete an entry, change the entry type to 'delete', so:
<pre class="literalblock">
   @delete{key1,
     author = {Charles Kingsley},
     check_sum = {3f9c929a1e9d2f179c1ef8fca02ceed4},
     title = {The Water Babies},
     year = {1916},
   }
</pre>
      <p>Will delete the entry with citekey 'key1' and will issues a 
      warning if that entry has changed.</p>
    </li>
    <li>
      Entries may be edited simply by including the edited entry, with the 
      caveat that entries are identified by citekey, so citekeys may not be
      changed.
    </li>
    <li>
      To add a new entry, simply include the new entry, using a key which 
      will not collide with any key in source bibliography.
    </li>
  </ul>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>bibliography</code></strong> (<a href="bkn.bibtex.bibliography.Bibliography-class.html" 
          class="link">Bibliography</a>) - a bibliography</li>
        <li><strong class="pname"><code>filename</code></strong> (string) - the filename of a BibTeX file from which the corrections should 
          be read</li>
    </ul></dd>
    <dt>Returns: None</dt>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== VARIABLES DETAILS ==================== -->
<a name="section-VariablesDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-VariablesDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="_MERGE_WARNING_TEMPLATE"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">_MERGE_WARNING_TEMPLATE</h3>
  <p>A format string for use in reporting errors when merging.</p>
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
'{0.parent_bib.name:10}:{0.citekey:20} {1}'
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<a name="_CORRECTION_WARNING_TEMPLATE"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">_CORRECTION_WARNING_TEMPLATE</h3>
  <p>A format string for use in reporting errors when applying 
  corrections.</p>
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
'Warning! Applying correction to {0.citekey} which has changed'
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<a name="_PAGE_RANGE_PATTERN"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">_PAGE_RANGE_PATTERN</h3>
  <p>Matches a set of digits seperated by hyphens. Used in 
  _normalize_fields.</p>
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
re.compile(r'(\d)-(\d)')
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bkn.bibtex-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bibkn/">bkn.bibtex</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Jul  4 23:10:58 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
